package com.maolong.ackpro.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component
@Slf4j
public class ReturnCallBack implements RabbitTemplate.ReturnsCallback {
    @Override
    public void returnedMessage(ReturnedMessage returned) {
        String message= Arrays.toString(returned.getMessage().getBody());
        log.info("消息{}被交换机{}退回，退回原因：{}，路由key：{}",message,returned.getExchange(),returned.getReplyText(),returned.getRoutingKey());
    }
    /**
     * 处理方式
     *  1：尝试重新调用
     *  2：落库处理，存入 mysql 数据库中
     */
}
